package com.zs4sdk.entity;

import com.common.library.entity.JSONResultEntity;
import com.common.library.util.Helper;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Administrator on 2018/4/24.
 */

public class Zs4GamePersonInfoEntity extends JSONResultEntity {
    public final static String COLUMN_LOGIN_NAME = "login_name";
    public static final String COLUMN_MOBILE = "mobile";
    public static final String COLUMN_NICKNAME = "nickname";  //原来为nickname  后来修改为login_name
    public static final String COLUMN_ISPWD = "ispwd";
    public static final String COLUMN_RESULT = "result";

    protected String nickname = "";
    protected String login_name = "";
    protected String mobile = "";
    protected int ispwd = 0;
    protected int result = 0;
    /**
     * 构造方法
     */
    public Zs4GamePersonInfoEntity(){

    }
    /**
     * 构造方法
     * @param json
     */
    public Zs4GamePersonInfoEntity(JSONObject json){
        this.fromJSON(json);
    }

    /**
     * 构造方法
     * @param jsonStr
     */
    public Zs4GamePersonInfoEntity(String jsonStr){
        try{
            this.fromJSON(new JSONObject(jsonStr));
        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void fromJSON(JSONObject json) {
        super.fromJSON(json);

        if(Helper.isNotEmpty(json)) {
            this.nickname = json.optString(COLUMN_NICKNAME);
            this.ispwd = json.optInt(COLUMN_ISPWD);
            this.result = json.optInt(COLUMN_RESULT);
            this.mobile = json.optString(COLUMN_MOBILE);
            login_name = json.optString(COLUMN_LOGIN_NAME);
        }
    }

    @Override
    public JSONObject toJSON() {
        JSONObject result = super.toJSON();
        try {
            result.put(COLUMN_NICKNAME, this.nickname);
            result.put(COLUMN_MOBILE, this.mobile);
            result.put(COLUMN_RESULT, this.result);
            result.put(COLUMN_LOGIN_NAME, this.login_name);
            result.put(COLUMN_ISPWD, this.ispwd);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return result;
    }
    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }


    public String getLoginName() {
        return login_name;
    }

    public void setLoginName(String login_name) {
        this.login_name = login_name;
    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }
}
